﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Platform.ObjectModel
{
	public static class LinqExtensions
	{

		public static IQueryable FreeTextSearch( this IQueryable query, string keywords )
		{
			var provider = query.Provider;

			Expression<Func<IQueryable, IQueryable>> call = ( q ) => LinqExtensions.FreeTextSearch( q, keywords );
			return provider.CreateQuery( call );
		}


		public static IQueryable<TModel> FreeTextSearch<TModel>( this IQueryable<TModel> query, string keywords )
		{
			var provider = query.Provider;

			Expression<Func<IQueryable<TModel>, IQueryable<TModel>>> call = ( q ) => LinqExtensions.FreeTextSearch<TModel>( q, keywords );
			return provider.CreateQuery<TModel>( call );
		}
	}
}
